package base.day16.polymorpic;

import base.day15.animal.Dog;

public class TestPolymorpic3 {
    public static void main(String[] args) {
        userAnimal(new Dog1());
        userAnimal(new Cat1());
    }
    public static void userAnimal(Animal1 a){
        a.eat();
        if (a instanceof Dog1){
            Dog1 dog1=(Dog1) a;
            dog1.method();
        }


    }

}
abstract class Animal1{
    public abstract void eat();
}
class Dog1 extends Animal1{
    public void eat(){
        System.out.println("狗吃肉");
    }
    public void method(){
        System.out.println("method.......");
    }

}
class Cat1 extends Animal1 {
    public void eat() {
        System.out.println("猫吃肉");
    }
}